<?php

use yii\db\Migration;

class m160114_102740_add_company_id_and_branch_id_to_department extends Migration
{
    public function up()
    {
        $this->addColumn('department', 'company_id', $this->integer());
        $this->createIndex('idx-department-company_id', 'department', 'company_id');
        $this->addForeignKey('fk-department-company_id', 'department', 'company_id', 'company', 'id', 'CASCADE');

        $this->addColumn('department', 'branch_id', $this->integer());
        $this->createIndex('idx-department-branch_id', 'department', 'branch_id');
        $this->addForeignKey('fk-department-branch_id', 'department', 'branch_id', 'branch', 'id', 'CASCADE');
    }

    public function down()
    {
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
